package 反射.动态代理;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * 动态代理
 */
public class DynamicProxyHandler implements InvocationHandler {
	private Object proxied;

	public DynamicProxyHandler(Object proxied) {
		this.proxied = proxied;
	}

	@Override
	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
		if (args != null) {
			if(args.length ==1){
				System.out.println("有参方法执行");
			}
			for (Object arg : args) {
				System.out.println("" + arg);
			}
		}else{
			System.out.println("无参方法执行");
		}


		return method.invoke(proxied, args);
	}
}